ActionController::Routing::Routes.draw do |map|
   
  map.root :controller => "home"
  
  map.login   "login", :controller => "user_sessions", :action => "new"
  map.logout  "logout", :controller => "user_sessions", :action => "destroy"
  
  map.about     "about", :controller => "home", :action => "about"
  map.services  "services", :controller => "home", :action => "services"
  map.contact   "contact", :controller => "home", :action => "contact"
  
  map.blog    'blog', :controller => 'blog', :action => 'index'
  map.connect '/blog/:year/:month/:day/:stub', 
              :controller   => 'blog', 
              :action       => 'show', 
              :requirements => {
                :year   => /(20)\d\d/,
                :month  => /[01]?\d/,
                :day    => /\d{1,2}/,
                :stub   => /[\w-]+/
              }
              
  map.connect '/blog/:year/:month', 
              :controller   => 'blog', 
              :action       => 'date_archive', 
              :requirements => {
                :year   => /(20)\d\d/,
                :month  => /[01]?\d/
              }
              
  map.connect '/blog/category/:tag', 
              :controller   => 'blog', 
              :action       => 'category'
                
  map.resources :user_sessions
  map.resources :users
  
  map.admin  "admin", :controller => "admin"
  map.namespace :admin do |admin|
    admin.resources :blog_posts
    admin.resources :users
    admin.resources :tags
    admin.resources :contractor_tags
    admin.resources :change_orders
    admin.resources :tasks
    admin.resources :payments
    admin.resources :milestones, :member => {:show_remote_form => :get} do |m|
      m.resources   :tasks, :member => {:show_remote_form => :get}
    end
    admin.resources :sub_contractors
    admin.resources :projects, :member => {:show_remote_form => :get} do |p|
      p.resources   :milestones, :member => {:show_remote_form => :get}
      p.resources   :payments, :member => {:show_remote_form => :get}
    end
  end

  map.connect ':controller/:action/:id'
  map.connect ':controller/:action/:id.:format'
  
end
